using ConfClient;
using SvCore.Tcp;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Zpb;

public class WdSkillsLine : MonoBehaviour
{
    public TMP_Text TextName;
    public TMP_Text TextLevel;
    public TMP_Text TextDesc;
    public TMP_Text TextPot;
    public Button ButtonLevelup;

    private string SkillId = "";

    // Start is called before the first frame update
    void Start()
    {
        ButtonLevelup.onClick.AddListener(OnButtonLevelup);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void Setup(InfoSkill skill, ConfigSkill conf)
    {
        SkillId = conf.Id;

        TextName.text = conf.Id;
        TextLevel.text = $"{skill.Level}";

        var confDesc = Zsc.GetSkillLevelDesc(skill.Level);
        TextDesc.text = confDesc.Desc.ColorReplace(confDesc.Color);

        var potlevelup = Zsc.GetPotLevelup(skill.Level);
        TextPot.text = $"{potlevelup}";
        ButtonLevelup.ButtonSetEnable(GameData.PlayerInfoBase.Pot >= potlevelup);
    }
    public void OnButtonLevelup()
    {
        var Req = new C2GSkillLevelup();
        Req.SkillId = SkillId;
        MySocket.Send(Req);
    }
}
